package org.jeecg.modules.fund.controller;

import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.fund.entity.StockIndex;
import org.jeecg.modules.fund.job.FundAllCodeJob;
import org.jeecg.modules.fund.service.IFundLibraryService;
import org.jeecg.modules.fund.service.IFundValueService;
import org.jeecg.modules.fund.service.IStockLibraryService;
import org.jeecg.modules.fund.service.IStockValueService;
import org.jeecg.modules.fund.util.FundAllCodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 使用方式：
 * 一、基金
 * ①生成基金库代码
 * ②生成基金净值
 * 二、股票
 * ①生成股票的基本信息：代码、简称 => 调用接口“createStockCode”
 * ②生成股票的每日净值数据
 */
@RestController
@Api(tags = "运维生成数据专用")
@RequestMapping("/sys/fund/stock/auth")
@Slf4j
public class NoAuthController {
    @Autowired
    private IStockLibraryService stockLibraryService;
    @Autowired
    private IStockValueService stockValueService;
    @Autowired
    private IFundLibraryService fundLibraryService;
    @Autowired
    private FundAllCodeJob allCodeJob;
    @Autowired
    private IFundValueService fundValueService;

    @AutoLog(value = "生成基金代码")
    @RequestMapping(value = "/createFundCode", method = RequestMethod.GET)
    public void createFundCode() throws InterruptedException {
        allCodeJob.execute();
    }

    @AutoLog(value = "生成基金净值")
    @RequestMapping(value = "/createFundValue", method = RequestMethod.GET)
    public void createFundValue() throws InterruptedException {
        fundValueService.batchUpdateVal(true);
    }


    //------------------------------------------------------------------------------------------------------------------------------------------
    /**
     * 生成股票代码
     * @param
     * @return
     */
    @AutoLog(value = "生成股票代码")
    @RequestMapping(value = "/createStockCode", method = RequestMethod.GET)
    public void createStockCode() {
        stockLibraryService.create();
    }

    /**
     * 生成股票代码
     * @param
     * @return
     */
    @AutoLog(value = "生成股票净值")
    @RequestMapping(value = "/createStockValue", method = RequestMethod.GET)
    public void createStockValue() {
        stockValueService.createAllStockValue();
    }
}
